package com.oldbook.manage.service.impl;

import java.util.List;

import com.oldbook.common.utils.DateUtils;
import com.oldbook.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.oldbook.manage.mapper.StudentInfoMapper;
import com.oldbook.manage.domain.StudentInfo;
import com.oldbook.manage.service.IStudentInfoService;

/**
 * 学生信息维护Service业务层处理
 * 
 * @author Exiaoke
 * @date 2025-02-18
 */
@Service
public class StudentInfoServiceImpl implements IStudentInfoService 
{
    @Autowired
    private StudentInfoMapper studentInfoMapper;

    /**
     * 查询学生信息维护
     * 
     * @param studentId 学生信息维护主键
     * @return 学生信息维护
     */
    @Override
    public StudentInfo selectStudentInfoByStudentId(Long studentId)
    {
        return studentInfoMapper.selectStudentInfoByStudentId(studentId);
    }

    /**
     * 查询学生信息维护列表
     * 
     * @param studentInfo 学生信息维护
     * @return 学生信息维护
     */
    @Override
    public List<StudentInfo> selectStudentInfoList(StudentInfo studentInfo)
    {
        return studentInfoMapper.selectStudentInfoList(studentInfo);
    }

    /**
     * 新增学生信息维护
     * 
     * @param studentInfo 学生信息维护
     * @return 结果
     */
    @Override
    public int insertStudentInfo(StudentInfo studentInfo)
    {
        studentInfo.setCreateTime(DateUtils.getNowDate());
        studentInfo.setPassword(SecurityUtils.encryptPassword(studentInfo
                .getPassword()));
        return studentInfoMapper.insertStudentInfo(studentInfo);
    }

    /**
     * 修改学生信息维护
     * 
     * @param studentInfo 学生信息维护
     * @return 结果
     */
    @Override
    public int updateStudentInfo(StudentInfo studentInfo)
    {
        studentInfo.setUpdateTime(DateUtils.getNowDate());
        studentInfo.setPassword(SecurityUtils.encryptPassword(studentInfo.getPassword()));
        return studentInfoMapper.updateStudentInfo(studentInfo);
    }

    /**
     * 批量删除学生信息维护
     * 
     * @param studentIds 需要删除的学生信息维护主键
     * @return 结果
     */
    @Override
    public int deleteStudentInfoByStudentIds(Long[] studentIds)
    {
        return studentInfoMapper.deleteStudentInfoByStudentIds(studentIds);
    }

    /**
     * 删除学生信息维护信息
     * 
     * @param studentId 学生信息维护主键
     * @return 结果
     */
    @Override
    public int deleteStudentInfoByStudentId(Long studentId)
    {
        return studentInfoMapper.deleteStudentInfoByStudentId(studentId);
    }
}
